import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select        # 下拉控件
# 实例化驱动
driver = webdriver.Chrome()
# 全屏化
driver.maximize_window()
# 打开网页
driver.get("http://sahitest.com/demo/selectTest.htm")
"""
# 第一种方式：根据value值进行下拉选择
# 定位到要操作的下拉框
time.sleep(2)
s1Id = driver.find_element(By.ID,"s1Id")
# 实例化控件
s1 = Select(s1Id)
s1.select_by_value("o3")
"""
"""
#第二种方式：根据索引值来选择
s1 = driver.find_element(By.ID,"s1")
s_s1 = Select(s1)
s_s1.select_by_index(2)
"""
# 第三种方式：手动输入内容进行选择
# 先定位到你要操作的下拉框
time.sleep(5)
testInputEvent = driver.find_element(By.ID,"testInputEvent")
s1 = Select(testInputEvent)
s1.select_by_visible_text("Option 3")


time.sleep(5)

